import request from '../utils/request'
export function getDataList (id, itemId, index, pageSize, fileName) {
  return request.get('system/data/getDataList', {
    params: {
      id: id,
      index: index,
      pageSize: pageSize,
      fileName: fileName,
      itemId: itemId
    }
  })
}

// 资料管理列表分类和数量
export function getItemList (id) {
  return request.get('/system/data/itemList', {
    params: {
      item: id
    }
  })
}

// 查看资料类目列表
export function getdataItems (index, id, pageSize) {
  return request.get('system/dataItems/list', {
    params: {
      index: index,
      item: id,
      pageSize: pageSize
    }
  })
}

// 新增文件
export function addData (learningDTOList) {
  return request.post('system/data/addData', { learningDTOList })
}

// 删除文件
export function deleteData (ids) {
  return request.post('system/data/removeData', { ids })
}

// 下载文档
export function uploadDocument (id) {
  return request.get('/system/file/download', { params: { id }, responseType: 'blob' })
}
// 下载视频模型
export const downloadModel = (modelId) => {
  return request.get('/system/dataModel/download', { params: { modelId }, responseType: 'blob' })
}
// 编辑文件
export function editDoc (learningDTO, learningId) {
  return request.post(`system/data/editData?learningId=${learningId}`, learningDTO)
}

// 添加类目
export function addItem (statisticalItemsDTO) {
  return request.post('/system/dataItems/items', statisticalItemsDTO)
}

// 更新类目
export function updateItem (id, name) {
  return request.post(`/system/dataItems/updateItem?id=${id}&name=${name}`)
}

// 删除项目
export function deleteItem (id) {
  return request.post(`system/dataItems/deleteItem?id=${id}`)
}

// 根据id预览pdf/word/ppt
export function readFile (id) {
  return request.get(`/system/file/read?id=${id}`, {
    responseType: 'blob'
  })
}
